//
//  CustomNavigationController.swift
//  Practice
//
//  Created by miaozhihui on 2017/1/9.
//  Copyright © 2017年 DeKuTree. All rights reserved.
//

import UIKit

class CustomNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBar.isHidden = true
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            if let vc = viewController as? BaseController  {
                var title = "返回"
                if childViewControllers.count == 1 {
                    title = childViewControllers.first?.title ?? ""
                }
                
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: title, target: self, action: #selector(popViewController(animated:)),isBack: true)
            }
        }
        super.pushViewController(viewController, animated: animated)
    }
}
